package com.bigmodel.controller;

import cn.hutool.core.lang.UUID;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.bigmodel.vo.RequestAmdbAttrVO;
import com.bigmodel.vo.ResponseResult;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/")
public class BeiHangController {


    @GetMapping("/bi/query/flow_log")
    public JSONObject flow_log(@RequestParam String start_time,
                               @RequestParam String end_time) {
        String data = "{\n" +
                "  \"code\": 200,\n" +
                "  \"message\": \"操作成功\",\n" +
                "  \"data\": {\n" +
                "    \"table\": [\n" +
                "      {\n" +
                "        \"id\": 0,\n" +
                "        \"time\": 0,\n" +
                "        \"src_ip\": 0,\n" +
                "        \"dst_ip\": 0,\n" +
                "        \"bytes_in\": 120,\n" +
                "        \"bytes_out\": 891,\n" +
                "        \"user_name\": \"cmcc\",\n" +
                "        \"domain\": \"optimizationguide-pa.googleapis.com\",\n" +
                "        \"user_mac\": \"08:00:27:46:29:59\",\n" +
                "        \"pppoe_ip\": 0,\n" +
                "        \"src_ip_str\": \"193.10.168.192\",\n" +
                "        \"dst_ip_str\": \"106.160.217.172\",\n" +
                "        \"pppoe_ip_str\": \"\",\n" +
                "        \"time_str\": \"2023-12-14 17:30:49\"\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": 1,\n" +
                "        \"time\": 0,\n" +
                "        \"src_ip\": 0,\n" +
                "        \"dst_ip\": 0,\n" +
                "        \"bytes_in\": 6850,\n" +
                "        \"bytes_out\": 20214,\n" +
                "        \"user_name\": \"cmcc\",\n" +
                "        \"domain\": \"go.microsoft.com\",\n" +
                "        \"user_mac\": \"08:00:27:46:29:59\",\n" +
                "        \"pppoe_ip\": 0,\n" +
                "        \"src_ip_str\": \"193.10.168.192\",\n" +
                "        \"dst_ip_str\": \"214.168.25.184\",\n" +
                "        \"pppoe_ip_str\": \"\",\n" +
                "        \"time_str\": \"2023-12-14 17:30:34\"\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": 2,\n" +
                "        \"time\": 0,\n" +
                "        \"src_ip\": 0,\n" +
                "        \"dst_ip\": 0,\n" +
                "        \"bytes_in\": 0,\n" +
                "        \"bytes_out\": 512,\n" +
                "        \"user_name\": \"cmcc\",\n" +
                "        \"domain\": \"\",\n" +
                "        \"user_mac\": \"08:00:27:46:29:59\",\n" +
                "        \"pppoe_ip\": 0,\n" +
                "        \"src_ip_str\": \"193.10.168.192\",\n" +
                "        \"dst_ip_str\": \"252.0.0.224\",\n" +
                "        \"pppoe_ip_str\": \"\",\n" +
                "        \"time_str\": \"2023-12-14 17:30:34\"\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": 3,\n" +
                "        \"time\": 0,\n" +
                "        \"src_ip\": 0,\n" +
                "        \"dst_ip\": 0,\n" +
                "        \"bytes_in\": 0,\n" +
                "        \"bytes_out\": 388,\n" +
                "        \"user_name\": \"cmcc\",\n" +
                "        \"domain\": \"\",\n" +
                "        \"user_mac\": \"08:00:27:46:29:59\",\n" +
                "        \"pppoe_ip\": 0,\n" +
                "        \"src_ip_str\": \"193.10.168.192\",\n" +
                "        \"dst_ip_str\": \"42.163.217.172\",\n" +
                "        \"pppoe_ip_str\": \"\",\n" +
                "        \"time_str\": \"2023-12-14 17:30:28\"\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": 4,\n" +
                "        \"time\": 0,\n" +
                "        \"src_ip\": 0,\n" +
                "        \"dst_ip\": 0,\n" +
                "        \"bytes_in\": 0,\n" +
                "        \"bytes_out\": 388,\n" +
                "        \"user_name\": \"cmcc\",\n" +
                "        \"domain\": \"\",\n" +
                "        \"user_mac\": \"08:00:27:46:29:59\",\n" +
                "        \"pppoe_ip\": 0,\n" +
                "        \"src_ip_str\": \"193.10.168.192\",\n" +
                "        \"dst_ip_str\": \"234.42.251.142\",\n" +
                "        \"pppoe_ip_str\": \"\",\n" +
                "        \"time_str\": \"2023-12-14 17:30:07\"\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": 5,\n" +
                "        \"time\": 0,\n" +
                "        \"src_ip\": 0,\n" +
                "        \"dst_ip\": 0,\n" +
                "        \"bytes_in\": 0,\n" +
                "        \"bytes_out\": 9363,\n" +
                "        \"user_name\": \"cmcc\",\n" +
                "        \"domain\": \"\",\n" +
                "        \"user_mac\": \"08:00:27:46:29:59\",\n" +
                "        \"pppoe_ip\": 0,\n" +
                "        \"src_ip_str\": \"193.10.168.192\",\n" +
                "        \"dst_ip_str\": \"250.255.255.239\",\n" +
                "        \"pppoe_ip_str\": \"\",\n" +
                "        \"time_str\": \"2023-12-14 17:30:01\"\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": 6,\n" +
                "        \"time\": 0,\n" +
                "        \"src_ip\": 0,\n" +
                "        \"dst_ip\": 0,\n" +
                "        \"bytes_in\": 0,\n" +
                "        \"bytes_out\": 868,\n" +
                "        \"user_name\": \"cmcc\",\n" +
                "        \"domain\": \"\",\n" +
                "        \"user_mac\": \"08:00:27:46:29:59\",\n" +
                "        \"pppoe_ip\": 0,\n" +
                "        \"src_ip_str\": \"193.10.168.192\",\n" +
                "        \"dst_ip_str\": \"250.255.255.239\",\n" +
                "        \"pppoe_ip_str\": \"\",\n" +
                "        \"time_str\": \"2023-12-14 17:30:01\"\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": 7,\n" +
                "        \"time\": 0,\n" +
                "        \"src_ip\": 0,\n" +
                "        \"dst_ip\": 0,\n" +
                "        \"bytes_in\": 0,\n" +
                "        \"bytes_out\": 388,\n" +
                "        \"user_name\": \"cmcc\",\n" +
                "        \"domain\": \"\",\n" +
                "        \"user_mac\": \"08:00:27:46:29:59\",\n" +
                "        \"pppoe_ip\": 0,\n" +
                "        \"src_ip_str\": \"193.10.168.192\",\n" +
                "        \"dst_ip_str\": \"10.43.251.142\",\n" +
                "        \"pppoe_ip_str\": \"\",\n" +
                "        \"time_str\": \"2023-12-14 17:29:46\"\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": 8,\n" +
                "        \"time\": 0,\n" +
                "        \"src_ip\": 0,\n" +
                "        \"dst_ip\": 0,\n" +
                "        \"bytes_in\": 0,\n" +
                "        \"bytes_out\": 868,\n" +
                "        \"user_name\": \"cmcc\",\n" +
                "        \"domain\": \"\",\n" +
                "        \"user_mac\": \"08:00:27:46:29:59\",\n" +
                "        \"pppoe_ip\": 0,\n" +
                "        \"src_ip_str\": \"193.10.168.192\",\n" +
                "        \"dst_ip_str\": \"250.255.255.239\",\n" +
                "        \"pppoe_ip_str\": \"\",\n" +
                "        \"time_str\": \"2023-12-14 17:28:01\"\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": 9,\n" +
                "        \"time\": 0,\n" +
                "        \"src_ip\": 0,\n" +
                "        \"dst_ip\": 0,\n" +
                "        \"bytes_in\": 0,\n" +
                "        \"bytes_out\": 388,\n" +
                "        \"user_name\": \"cmcc\",\n" +
                "        \"domain\": \"\",\n" +
                "        \"user_mac\": \"08:00:27:46:29:59\",\n" +
                "        \"pppoe_ip\": 0,\n" +
                "        \"src_ip_str\": \"193.10.168.192\",\n" +
                "        \"dst_ip_str\": \"106.160.217.172\",\n" +
                "        \"pppoe_ip_str\": \"\",\n" +
                "        \"time_str\": \"2023-12-14 17:27:50\"\n" +
                "      }\n" +
                "    ],\n" +
                "    \"total\": 930,\n" +
                "    \"download_url\": \"http://4k.dev.srun.com:8083/download/flow_log?start_time=2023-12-14 00:00:00&end_time=2023-12-14 23:59:59&src_ip=&dst_ip=&user_name=&domain=&user_mac=\",\n" +
                "    \"unit\": 1024\n" +
                "  }\n" +
                "}";
        return JSONUtil.parseObj(data);
    }

    /**
     * 数据库重启
     * @return
     */
    @GetMapping("/bi/query/flow_log/total_bytes")
    public JSONObject total_bytes(@RequestParam String start_time,
                               @RequestParam String end_time) {
        String data = "{\n" +
                "  \"code\": 200,\n" +
                "  \"message\": \"查询成功\",\n" +
                "  \"data\": {\n" +
                "    \"bytes_in\": 29989336,\n" +
                "    \"bytes_out\": 2141005,\n" +
                "    \"unit\": 1024\n" +
                "  }\n" +
                "}";
        return JSONUtil.parseObj(data);
    }


}
